import 'simditor/styles/simditor.css'

import $ from 'jquery'
import '../../../static/js/module.js'
import '../../../static/js/hotkeys.js'
import '../../../static/js/uploader.js'
import Simditor from '../../../static/js/simditor.js'

import defaultImage from 'assets/logo.png'

// import {loadToken} from 'common/js/editor.js'

export function simditor(dom) {
  return new Simditor({
    textarea: $(dom),
    toolbar: [
      'title',
      'bold',
      'italic',
      'underline',
      'strikethrough',
      'fontScale',
      'color',
      'ol',
      'ul',
      'code',
      'table',
      'link',
      'image',
      'hr',
      'indent',
      'outdent',
      'alignment'
    ],
    defaultImage,
    upload: {
      url: 'https://api.zgwyzxw.cn/files',
      fileKey: 'upload_file',
      params: {
        prefix: 'article'
        // token: loadToken()
      },
      connectionCount: 3,
      leaveConfirm: '正在上传,确定要取消上传文件吗?'
    },
    allowedAttributes: {
      img: ['src', 'alt', 'width', 'height', 'data-non-image']
    },
    // imageButton: ['upload', 'external'],
    imageButton: ['upload', 'external'],
    toolbarHidden: false,
    params: null,
    tabIndent: true,
    toolbarFloat: true,
    toolbarFloatOffset: 0,
    cleanPaste: false,
    pasteImage: true
  })
}
